<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'course.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="css/css.css" />
	<script type="text/javascript" src="js/jquery.min.js" ></script>
	
<!-- 	
	<link rel="stylesheet" type="text/css" href="styles.css">
	 -->

  </head>
  
  <body>
  
  	<div id="pageAll">
		<div class="pageTop">
			<div class="page">
				<img src="img/coin02.png" /><span><a href="#">首页</a>&nbsp;-&nbsp;-</span>&nbsp;课程管理
			</div>
		</div>

		<div class="page">
			<!-- user页面样式 -->
			<div class="connoisseur">
				<div class="conform">
					<form action="course/queryByPage" method="post" id="pager">
						<div class="cfD">
							<input type="hidden" id="currentPage" name="currentPage" value="${pageModel.currentPage }">
   							<input type="hidden" id="pageSize" name="pageSize" value="${pageModel.pageSize }">
							<input class="userinput" type="text" name="cname" placeholder="输入课程关键字" 
							value="<%=request.getParameter("cname") == null?"":request.getParameter("cname") %>" />	
							<button type="submit" class="userbtn">查&nbsp;&nbsp;&nbsp;&nbsp;询</button>
							<button type="button" class="userbtn" id="addnew">添加课程</button>
						</div>
					</form>
					
				</div>
				<!-- user 表格 显示 -->
				<div class="conShow">
					<table border="1" cellspacing="0" cellpadding="0">
						<tr>
							<td width="100px" class="tdColor tdC">课程编号</td>
							<td width="230px" class="tdColor">课程名称</td>
							<td width="260px" class="tdColor">课程描述</td>
							<td width="500px" class="tdColor">所属专业</td>
							<td width="200px" class="tdColor">授课老师</td>						
							<td width="150px" class="tdColor">操作</td>
						</tr>
					 <c:forEach items="${cours }" var="cl">
					 	<tr height="40px">
					 		<td width="100px" >${cl.cid }<input type="hidden" name="todell" value="${cl.cid }"/></td>
							<td width="230px" >${cl.cname }</td>
							<td width="260px" >${cl.cdetails }</td>
							<td width="500px" >
								<c:forEach items="${cl.majors }" var="m">
									${m.mname }&nbsp;&nbsp;&nbsp;&nbsp;
								</c:forEach>
							</td>
							<td width="200px" >${cl.teacher.tname}</td>
							<td width="150px" >
								<a href="course/toUpdate?cid=${cl.cid }"><img class="operation" src="img/update.png"></a> 
								<a href="javascript:del(${cl.cid}, '${cl.cname}');"><img class="operation delban" src="img/delete.png"></a>
							</td>
					 	</tr>
					 
				<!-- 删除弹出框 -->
				<div class="banDel" style="width:460px;height:280px;position: fixed;left:30%;top:15%; background-color: rgba(255,255,255,0.2);">
					<div class="delete">
						<div class="close">
							<a><img src="img/shanchu.png" /></a>
						</div>
						<p class="delP1">你确定要删除此条记录吗？</p>
						<p class="delP2">
							<a id="yesto" class="ok yes">确定</a><a class="ok no">取消</a>
						</p>
					</div>
				</div>
				<!-- 删除弹出框  end-->
					 </c:forEach>
						
					</table>
					<div class="paging">
						<%@include file="/pageBar.jsp" %>
						<%-- <jsp:include page="../../pageBar.jsp"></jsp:include> --%>
					</div>
				</div>
				<!-- user 表格 显示 end-->
			</div>
			<!-- user页面样式end -->
		</div>

	</div>

  
  </body>

<script type="text/javascript">
// 广告弹出框
/* $(".delban").click(function(){
  $(".banDel").show();
});
$(".close").click(function(){
  $(".banDel").hide();
});
$(".no").click(function(){
  $(".banDel").hide();
}); */
// 广告弹出框 end
 
 $(function () {
		$('#addnew').click(function(){
				window.location.href="course/toAdd";
		 });
    });

/* var flag = false;
 $(function () {
		$('#yesto').click(function(){
				flag = true;
		 });
    }); */

function del(id,cname){			
			if(confirm("确定要删除 "+cname+" 课程吗？")){
		//	alert(id);	
			var url = "course/delete?cid="+id;
			window.location.href=url;
	}
	}

</script>  
  
  
</html>
